Hi Tapio,
Yes a program requires a loop to keep doing something over and over.
None of the programs in any of the Threads survive power down unless you specifically download programs to Threads and then Flash "User Data". You should also check "Launch on Power Up" on the Config/Flash Screen for the Threads you would like to run on Power Up before Flashing "User Data". We don't recommend Flashing User Data if you can avoid it as it can make upgrading and so forth confusing. Usually you can have the PC Application you are using download and execute any necessary programs.
The Emergency Stop button in KMotionCNC will teminate all KFLOP Threads except Thread #1
HTH
Regards
TK